package cn.org.intelli.zffserver.configuration;

import org.beetl.core.Configuration;
import org.beetl.core.GroupTemplate;
import org.beetl.core.resource.StringTemplateResourceLoader;
import org.springframework.context.annotation.Bean;
import org.springframework.core.io.ClassPathResource;

import java.io.IOException;
import java.util.Properties;

@org.springframework.context.annotation.Configuration
public class BeetlConfiguration {
    @Bean
    public GroupTemplate groupTemplate() throws IOException {
        // 加载 Beetl 配置文件
        Properties beetlProperties = new Properties();
        beetlProperties.load(new ClassPathResource("beetl.properties").getInputStream());

        // 使用 Beetl 的 Configuration
        Configuration cfg = new Configuration(beetlProperties);

        // 创建资源加载器
        StringTemplateResourceLoader resourceLoader = new StringTemplateResourceLoader();

        return new GroupTemplate(resourceLoader, cfg);
    }
}
